<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Upload 上传 | MyWeb 4.x</title>
    <meta name="generator" content="VuePress 1.5.0">
    <link rel="icon" href="/my/favicon.ico">
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?c4e5f73318b5cb0c389e3d9a05f831cc";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
    <meta name="description" content="基于Vue + ElementUI 的web项目工程框架，专注于公检法行业中台系统快速搭建，框架已在多个项目实战检验。">
    <link rel="preload" href="/my/assets/css/0.styles.d7ae9199.css" as="style"><link rel="preload" href="/my/assets/js/app.2b2365a7.js" as="script"><link rel="preload" href="/my/assets/js/535.c100cd07.js" as="script"><link rel="preload" href="/my/assets/js/1307.1fbfd9b2.js" as="script"><link rel="preload" href="/my/assets/js/1025.8afc0690.js" as="script">
    <link rel="stylesheet" href="/my/assets/css/0.styles.d7ae9199.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/my/" class="home-link router-link-active"><img src="/my/img/logo.png" alt="MyWeb 4.x" class="logo"> <span class="site-name can-hide">MyWeb 4.x</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/my/guide/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/my/guide/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Basic</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>Form</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/my/element/cascader.html" class="sidebar-link">Cascader 级联选择器</a></li><li><a href="/my/element/checkbox.html" class="sidebar-link">Checkbox 多选框</a></li><li><a href="/my/element/color-picker.html" class="sidebar-link">ColorPicker 颜色选择器</a></li><li><a href="/my/element/date-picker.html" class="sidebar-link">DatePicker 日期选择器</a></li><li><a href="/my/element/datetime-picker.html" class="sidebar-link">DateTimePicker 日期时间选择器</a></li><li><a href="/my/element/form.html" class="sidebar-link">Form 表单</a></li><li><a href="/my/element/input.html" class="sidebar-link">Input 输入框</a></li><li><a href="/my/element/input-number.html" class="sidebar-link">InputNumber 计数器</a></li><li><a href="/my/element/radio.html" class="sidebar-link">Radio 单选框</a></li><li><a href="/my/element/rate.html" class="sidebar-link">Rate 评分</a></li><li><a href="/my/element/select.html" class="sidebar-link">Select 选择器</a></li><li><a href="/my/element/slider.html" class="sidebar-link">Slider 滑块</a></li><li><a href="/my/element/switch.html" class="sidebar-link">Switch 开关</a></li><li><a href="/my/element/time-picker.html" class="sidebar-link">TimePicker 时间选择器</a></li><li><a href="/my/element/transfer.html" class="sidebar-link">Transfer 穿梭框</a></li><li><a href="/my/element/upload.html" aria-current="page" class="active sidebar-link">Upload 上传</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my/element/upload.html#点击上传" class="sidebar-link">点击上传</a></li><li class="sidebar-sub-header"><a href="/my/element/upload.html#用户头像上传" class="sidebar-link">用户头像上传</a></li><li class="sidebar-sub-header"><a href="/my/element/upload.html#照片墙" class="sidebar-link">照片墙</a></li><li class="sidebar-sub-header"><a href="/my/element/upload.html#文件缩略图" class="sidebar-link">文件缩略图</a></li><li class="sidebar-sub-header"><a href="/my/element/upload.html#图片列表缩略图" class="sidebar-link">图片列表缩略图</a></li><li class="sidebar-sub-header"><a href="/my/element/upload.html#上传文件列表控制" class="sidebar-link">上传文件列表控制</a></li><li class="sidebar-sub-header"><a href="/my/element/upload.html#拖拽上传" class="sidebar-link">拖拽上传</a></li><li class="sidebar-sub-header"><a href="/my/element/upload.html#手动上传" class="sidebar-link">手动上传</a></li><li class="sidebar-sub-header"><a href="/my/element/upload.html#attribute" class="sidebar-link">Attribute</a></li><li class="sidebar-sub-header"><a href="/my/element/upload.html#slot" class="sidebar-link">Slot</a></li><li class="sidebar-sub-header"><a href="/my/element/upload.html#methods" class="sidebar-link">Methods</a></li></ul></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Data</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Notice</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Navigation</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Others</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="upload-上传"><a href="#upload-上传" class="header-anchor">#</a> Upload 上传</h1> <p>通过点击或者拖拽上传文件</p> <h2 id="点击上传"><a href="#点击上传" class="header-anchor">#</a> 点击上传</h2> <!----><h2 id="用户头像上传"><a href="#用户头像上传" class="header-anchor">#</a> 用户头像上传</h2> <p>使用 <code>before-upload</code> 限制用户上传的图片格式和大小。</p> <!----><h2 id="照片墙"><a href="#照片墙" class="header-anchor">#</a> 照片墙</h2> <p>使用 <code>list-type</code> 属性来设置文件列表的样式。</p> <!----><h2 id="文件缩略图"><a href="#文件缩略图" class="header-anchor">#</a> 文件缩略图</h2> <p>使用 <code>scoped-slot</code> 去设置缩略图模版。</p> <!----><h2 id="图片列表缩略图"><a href="#图片列表缩略图" class="header-anchor">#</a> 图片列表缩略图</h2> <!----><h2 id="上传文件列表控制"><a href="#上传文件列表控制" class="header-anchor">#</a> 上传文件列表控制</h2> <p>通过 <code>on-change</code> 钩子函数来对列表进行控制</p> <!----><h2 id="拖拽上传"><a href="#拖拽上传" class="header-anchor">#</a> 拖拽上传</h2> <!----><h2 id="手动上传"><a href="#手动上传" class="header-anchor">#</a> 手动上传</h2> <!----><h2 id="attribute"><a href="#attribute" class="header-anchor">#</a> Attribute</h2> <table><thead><tr><th>参数</th> <th>说明</th> <th>类型</th> <th>可选值</th> <th>默认值</th></tr></thead> <tbody><tr><td>action</td> <td>必选参数，上传的地址</td> <td>string</td> <td>—</td> <td>—</td></tr> <tr><td>headers</td> <td>设置上传的请求头部</td> <td>object</td> <td>—</td> <td>—</td></tr> <tr><td>multiple</td> <td>是否支持多选文件</td> <td>boolean</td> <td>—</td> <td>—</td></tr> <tr><td>data</td> <td>上传时附带的额外参数</td> <td>object</td> <td>—</td> <td>—</td></tr> <tr><td>name</td> <td>上传的文件字段名</td> <td>string</td> <td>—</td> <td>file</td></tr> <tr><td>with-credentials</td> <td>支持发送 cookie 凭证信息</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>show-file-list</td> <td>是否显示已上传文件列表</td> <td>boolean</td> <td>—</td> <td>true</td></tr> <tr><td>drag</td> <td>是否启用拖拽上传</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>accept</td> <td>接受上传的<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept" target="_blank" rel="noopener noreferrer">文件类型<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>（thumbnail-mode 模式下此参数无效）</td> <td>string</td> <td>—</td> <td>—</td></tr> <tr><td>on-preview</td> <td>点击文件列表中已上传的文件时的钩子</td> <td>function(file)</td> <td>—</td> <td>—</td></tr> <tr><td>on-remove</td> <td>文件列表移除文件时的钩子</td> <td>function(file, fileList)</td> <td>—</td> <td>—</td></tr> <tr><td>on-success</td> <td>文件上传成功时的钩子</td> <td>function(response, file, fileList)</td> <td>—</td> <td>—</td></tr> <tr><td>on-error</td> <td>文件上传失败时的钩子</td> <td>function(err, file, fileList)</td> <td>—</td> <td>—</td></tr> <tr><td>on-progress</td> <td>文件上传时的钩子</td> <td>function(event, file, fileList)</td> <td>—</td> <td>—</td></tr> <tr><td>on-change</td> <td>文件状态改变时的钩子，添加文件、上传成功和上传失败时都会被调用</td> <td>function(file, fileList)</td> <td>—</td> <td>—</td></tr> <tr><td>before-upload</td> <td>上传文件之前的钩子，参数为上传的文件，若返回 false 或者返回 Promise 且被 reject，则停止上传。</td> <td>function(file)</td> <td>—</td> <td>—</td></tr> <tr><td>before-remove</td> <td>删除文件之前的钩子，参数为上传的文件和文件列表，若返回 false 或者返回 Promise 且被 reject，则停止删除。</td> <td>function(file, fileList)</td> <td>—</td> <td>—</td></tr> <tr><td>list-type</td> <td>文件列表的类型</td> <td>string</td> <td>text/picture/picture-card</td> <td>text</td></tr> <tr><td>auto-upload</td> <td>是否在选取文件后立即进行上传</td> <td>boolean</td> <td>—</td> <td>true</td></tr> <tr><td>file-list</td> <td>上传的文件列表, 例如: [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}]</td> <td>array</td> <td>—</td> <td>[]</td></tr> <tr><td>http-request</td> <td>覆盖默认的上传行为，可以自定义上传的实现</td> <td>function</td> <td>—</td> <td>—</td></tr> <tr><td>disabled</td> <td>是否禁用</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>limit</td> <td>最大允许上传个数</td> <td>number</td> <td>—</td> <td>—</td></tr> <tr><td>on-exceed</td> <td>文件超出个数限制时的钩子</td> <td>function(files, fileList)</td> <td>—</td> <td>-</td></tr></tbody></table> <h2 id="slot"><a href="#slot" class="header-anchor">#</a> Slot</h2> <table><thead><tr><th>name</th> <th>说明</th></tr></thead> <tbody><tr><td>trigger</td> <td>触发文件选择框的内容</td></tr> <tr><td>tip</td> <td>提示说明文字</td></tr></tbody></table> <h2 id="methods"><a href="#methods" class="header-anchor">#</a> Methods</h2> <table><thead><tr><th>方法名</th> <th>说明</th> <th>参数</th></tr></thead> <tbody><tr><td>clearFiles</td> <td>清空已上传的文件列表（该方法不支持在 before-upload 中调用）</td> <td>—</td></tr> <tr><td>abort</td> <td>取消上传请求</td> <td>（ file: fileList 中的 file 对象 ）</td></tr> <tr><td>submit</td> <td>手动上传文件列表</td> <td>—</td></tr></tbody></table></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/my/element/transfer.html" class="prev">
        Transfer 穿梭框
      </a></span> <span class="next"><a href="/my/element/badge.html">
        Badge 标记
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/my/assets/js/app.2b2365a7.js" defer></script><script src="/my/assets/js/535.c100cd07.js" defer></script><script src="/my/assets/js/1307.1fbfd9b2.js" defer></script><script src="/my/assets/js/1025.8afc0690.js" defer></script>
  </body>
</html>
